home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb11.zip / MATHTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1985-07-13  |  4KB  |  149 lines

  1. program mathtest;
  2. {
  3. This program performs timing tests on various floating
  4. point arithmetic operations.
  5.  
  6.  
  7. Source: "8087 Support: That Much Faster?", TUG Lines Volume I Issue 4
  8. Author: Richard Brush
  9. Application: IBM PC and true compatibles
  10. }
  11.  
  12. {$R+}
  13.  
  14. label done;
  15. var
  16.   x,y,z: array[0..255] of real;
  17.   i,j,jmax,n:integer;
  18.  
  19. {$I B:TIMEPACK.PAS}
  20.  
  21. {
  22. TimePack - a collection of procedures related to real time clock.
  23. The following procedures are included :
  24.  
  25. procedure getime (var hrs,min,sec,csec:integer);
  26. procedure Telapsed (hrs1,min1,sec1,csec1,hrs2,min2,sec2,csec2:integer;
  27.                     var Timdif:real);
  28. procedure Twait (time:real);
  29. }
  30.  
  31.  
  32. begin {mathtest}
  33.   for i:= 0 to 255 do
  34.     begin
  35.       x[i]:=random;
  36.       y[i]:=random;
  37.     end {for};
  38.   while true do
  39.     begin
  40.       repeat
  41.         ClrScr;
  42.         writeln ('type in number to select operation, according to menu:');
  43.         writeln ('  0:  stop');
  44.         writeln ('  1:  null loop');
  45.         writeln ('  2:  add');
  46.         writeln ('  3:  subtract');
  47.         writeln ('  4:  multiply');
  48.         writeln ('  5:  divide');
  49.         writeln ('  6:  sqrt');
  50.         writeln ('  7:  sin');
  51.         writeln ('  8:  cos');
  52.         writeln ('  9:  exp');
  53.         writeln ('  10: Logn');
  54.         writeln ('  11: Arctan');
  55.         writeln ('  12: compare');
  56.         writeln ('  13: zero test');
  57.         readln (n);
  58.       until n in [0..13];
  59.       if n=0 then goto done;
  60.       repeat
  61.         writeln ('type in number of iterations (1..32767)');
  62.         readln (jmax);
  63.       until (jmax >= 0) and (jmax <= maxint);
  64.       getime (hrs1,min1,sec1,csec1);
  65.       case n of
  66.         1:  for j:=1 to jmax do
  67.               begin
  68.                 i:= Lo(j);
  69.                 x[i]:= x[i]; {null operation}
  70.               end;
  71.         2:  for j:=1 to jmax do
  72.               begin
  73.                 i:= Lo(j);
  74.                 z[i]:= x[i] + y[i];
  75.               end;
  76.         3:  for j:=1 to jmax do
  77.               begin
  78.                 i:= Lo(j);
  79.                 z[i]:= x[i] - y[i];
  80.               end;
  81.         4:  for j:=1 to jmax do
  82.               begin
  83.                 i:= Lo(j);
  84.                 z[i]:= x[i] * y[i];
  85.               end;
  86.         5:  for j:=1 to jmax do
  87.               begin
  88.                 i:= Lo(j);
  89.                 z[i]:= x[i] / y[i];
  90.               end;
  91.         6:  for j:=1 to jmax do
  92.               begin
  93.                 i:= Lo(j);
  94.                 z[i]:= sqrt ( x[i] );
  95.               end;
  96.         7:  for j:=1 to jmax do
  97.               begin
  98.                 i:= Lo(j);
  99.                 z[i]:= sin ( x[i] );
  100.               end;
  101.         8:  for j:=1 to jmax do
  102.               begin
  103.                 i:= Lo(j);
  104.                 z[i]:= cos ( x[i] );
  105.               end;
  106.         9:  for j:=1 to jmax do
  107.               begin
  108.                 i:= Lo(j);
  109.                 z[i]:= exp ( x[i] );
  110.               end;
  111.         10: for j:=1 to jmax do
  112.               begin
  113.                 i:= Lo(j);
  114.                 z[i]:= Ln ( x[i] );
  115.               end;
  116.         11: for j:=1 to jmax do
  117.               begin
  118.                 i:= Lo(j);
  119.                 z[i]:= Arctan ( x[i] );
  120.               end;
  121.         12:  for j:=1 to jmax do
  122.               begin
  123.                 i:= Lo(j);
  124.                 if x[i] = y[i] then
  125.                   begin
  126.                   end;
  127.               end;
  128.         13:  for j:=1 to jmax do
  129.               begin
  130.                 i:= Lo(j);
  131.                 if x[i] = 0.0 then
  132.                   begin
  133.                   end;
  134.               end;
  135.       end {case};
  136.       getime (hrs2,min2,sec2,csec2);
  137.       Telapsed (hrs1,min1,sec1,csec1,hrs2,min2,sec2,csec2,Timdif);
  138.       { Beep speaker. }
  139.       Sound (500);
  140.       Delay(200);
  141.       NoSound;
  142.       writeln ('hit any key to continue');
  143.       repeat
  144.       until KeyPressed;
  145.     end {while};
  146. done:
  147. end {mathtest}.
  148.  
  149.